package features;

import javax.swing.tree.DefaultMutableTreeNode;

import operationSolids.CompoundSolid;
import operationSolids.OperationSphericalHoleBottom;

import CAD.MainFrame;

public class SphericalHoleBottom extends Feature
{
	private float radius = 0;
 	private float depth = 0;
	public SphericalHoleBottom(int type, Feature Mother, String name, float radius, float depth, float x, float y, float z, int face) 
	{
		super(type, Mother, name);
		this.radius = radius;
		this.depth = depth;
		this.feature = new OperationSphericalHoleBottom(name, depth, 2 * radius);
 		create(x, y, z, face);
 		MainFrame.features.add(this);
 		MainFrame.refreshJTree();
	}
	void translate() 
	{
		feature.translate(placement.getX(), placement.getY(), placement.getZ());	
 		switch (MainFrame.Face) 
 		{
 		case MainFrame.BACKFACE:
 			feature.translate(-MainFrame.block.width/2, MainFrame.block.length/2,MainFrame.block.height/2);
 			break;
 		case MainFrame.FRONTFACE:
 			feature.translate(-MainFrame.block.width/2, MainFrame.block.length/2,MainFrame.block.height/2);
 			break;
 		case MainFrame.EASTFACE:
 			feature.translate(-MainFrame.block.length/2,MainFrame.block.width/2,MainFrame.block.height/2 );
 			break;
 		case MainFrame.WESTFACE:
 			feature.translate(-MainFrame.block.length/2,MainFrame.block.width/2,MainFrame.block.height/2 );
 			break;
 		case MainFrame.LOWERFACE:
 			feature.translate(-MainFrame.block.width/2, MainFrame.block.height/2,MainFrame.block.length/2);
 			break;
 		case MainFrame.TOPFACE:
 			feature.translate(-MainFrame.block.width/2, MainFrame.block.height/2,MainFrame.block.length/2);
 			break;

 		default:
 			System.out.println("erro");
 			break;
 		}
	}
	void compound() 
	{
 		MainFrame.block  = new Block ("comp",CompoundSolid.DIFFERENCE,MainFrame.block, feature);
	}
	public void drawNode(DefaultMutableTreeNode node) 
	{
		node.add(new DefaultMutableTreeNode("Radius:"+radius+"mm"));
 		node.add(new DefaultMutableTreeNode("Depth:"+depth+"mm"));
	}
	public float getRadius() 
	{
 		return radius;
 	}
 	public float getDepth() 
 	{
 		return depth;
 	}
}
